/*
* 操作mutations的对象
通过mutation间接更新state的方法对象
* */

import {
    RECEIVE_LOGINSTATE,
} from './mutation-types'
import { requestLogin } from '../api';
import { defaultVue } from '../main';

export default {

  async checkLogin({commit},json){
      const result = await requestLogin(json);
      //判断
      if(result.message==="success"){
          commit(RECEIVE_LOGINSTATE,result.data);
          sessionStorage.setItem("user",JSON.stringify(result.data));
          defaultVue.$router.push('/');
      }
  },


}
